Clean up gdk_draw_drawable() composite handling
authorAlexander Larsson <alexl@redhat.com>
Tue, 25 Aug 2009 08:34:10 +0000 (10:34 +0200)
committerAlexander Larsson <alexl@redhat.com>
Tue, 25 Aug 2009 08:37:18 +0000 (10:37 +0200)
Instead of doing some magic in gdk_draw_drawable() to avoid double
offsetting when calling gdk_draw_drawable on the impl we call
the vfunc directly on the impl. Thus removing the weird magic from
gdk_draw_drawable().

I tested this with the testgtk test "text", where if the original magic
code is disabled typing a newline in the middle of a text line causes
the double offset issue to appear.

gdk/gdkdraw.c
gdk/gdkpixmap.c
gdk/gdkwindow.c

index 041d94e682ee9a77963912bc01c4cfa02c1db4df..829dd2ba6192245c5d27b386f379705ff93c7cc4 100644 (file)
@@ -634,7 +634,7 @@ gdk_draw_drawable (GdkDrawable *drawable,
                   gint         width,
                   gint         height)
 {
-  GdkDrawable *composite, *composite_impl;
+  GdkDrawable *composite;
   gint composite_x_offset = 0;
   gint composite_y_offset = 0;
 
@@ -663,24 +663,13 @@ gdk_draw_drawable (GdkDrawable *drawable,
                                                           &composite_x_offset,
                                                           &composite_y_offset);
 
-  /* The draw_drawable call below is will recurse into gdk_draw_drawable again,
-   * specifying the right impl for the destination. This means the composite
-   * we got here will be fed to get_composite_drawable again, which is a problem
-   * for window as that causes double the composite offset. Avoid this by passing
-   * in the impl directly.
-   */
-  if (GDK_IS_WINDOW (composite))
-    composite_impl = GDK_WINDOW_OBJECT (src)->impl;
-  else
-    composite_impl = composite;
-
   /* TODO: For non-native windows this may copy stuff from other overlapping
      windows. We should clip that and (for windows with bg != None) clear that
      area in the destination instead. */
 
   if (GDK_DRAWABLE_GET_CLASS (drawable)->draw_drawable_with_src)
     GDK_DRAWABLE_GET_CLASS (drawable)->draw_drawable_with_src (drawable, gc,
-                                                              composite_impl,
+                                                              composite,
                                                               xsrc - composite_x_offset,
                                                               ysrc - composite_y_offset,
                                                               xdest, ydest,
@@ -688,7 +677,7 @@ gdk_draw_drawable (GdkDrawable *drawable,
                                                               src);
   else /* backwards compat for old out-of-tree implementations of GdkDrawable (are there any?) */
     GDK_DRAWABLE_GET_CLASS (drawable)->draw_drawable (drawable, gc,
-                                                     composite_impl,
+                                                     composite,
                                                      xsrc - composite_x_offset,
                                                      ysrc - composite_y_offset,
                                                      xdest, ydest,
index 3d298057701b648382173ac1f1ae1900a1c61dc0..919a20252fcd27ed2f18a0fdc669affab26d8449 100644 (file)
@@ -385,10 +385,14 @@ gdk_pixmap_draw_drawable (GdkDrawable *drawable,
 {
   GdkPixmapObject *private = (GdkPixmapObject *)drawable;
 
-  _gdk_gc_remove_drawable_clip (gc);  
-  gdk_draw_drawable (private->impl, gc, src, xsrc, ysrc,
-                     xdest, ydest,
-                     width, height);
+  _gdk_gc_remove_drawable_clip (gc);
+  /* Call the method directly to avoid getting the composite drawable again */
+  GDK_DRAWABLE_GET_CLASS (private->impl)->draw_drawable_with_src (private->impl, gc,
+                                                                 src,
+                                                                 xsrc, ysrc,
+                                                                 xdest, ydest,
+                                                                 width, height,
+                                                                 original_src);
 }
 
 static void
index 977861e8314ea170a767575c7ece983fd9faa632..7ca6c3c9d06b877a21cb9ecc421d37b84b4a2a5b 100644 (file)
@@ -3654,8 +3654,14 @@ gdk_window_draw_drawable (GdkDrawable *drawable,
 
   BEGIN_DRAW;
 
-  gdk_draw_drawable (impl, gc, src, xsrc, ysrc,
-                    xdest - x_offset, ydest - y_offset, width, height);
+  /* Call the method directly to avoid getting the composite drawable again */
+  GDK_DRAWABLE_GET_CLASS (impl)->draw_drawable_with_src (impl, gc,
+                                                        src,
+                                                        xsrc, ysrc,
+                                                        xdest - x_offset,
+                                                        ydest - y_offset,
+                                                        width, height,
+                                                        original_src);
 
   if (!private->paint_stack)
     {